package com.lbj.mall.product.web;

import com.lbj.mall.product.entity.vo.SkuItemVo;
import com.lbj.mall.product.service.SkuInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

@Slf4j
@Controller
public class ItemController {

    @Autowired
    SkuInfoService skuInfoService;

    @GetMapping("/{skuId}.html")
    public String item(@PathVariable("skuId") Long skuId, Model model) throws Exception {
        log.info("skuId --> " + skuId);
        SkuItemVo itemVo = skuInfoService.querySkuItem(skuId);
        model.addAttribute("result", itemVo);
        log.info("itemVo --> " + itemVo);
        return "item";
    }
}

